<template>
  <div class="main-container">
    <div class="welcome-section">
      <p class="welcome-title">欢迎来到空军基地</p>
      
    </div>

    <div class="navigation-grid">
      <router-link to="/map" class="nav-card">
        <img src="../assets/地图缩略.png" alt="钓鱼地图" class="nav-image">
        <div class="nav-content">
          <h3>查看钓鱼地图</h3>
          <p>全球地图，卫星地图、交通地图及地形地图随意切换</p>
        </div>
      </router-link>

      <router-link to="/fish" class="nav-card">
        <img src="../assets/大全缩略.png" alt="鱼类百科" class="nav-image">
        <div class="nav-content">
          <h3>鱼类百科</h3>
          <p>详尽的淡水鱼类信息，包括习性、钓法和最佳饵料</p>
        </div>
      </router-link>

      <router-link to="/gear" class="nav-card">
        <img src="../assets/商城缩略.png" alt="二手渔具" class="nav-image">
        <div class="nav-content">
          <h3>二手渔具</h3>
          <p>专业渔具二手售卖商城，助您选择最适合的装备</p>
        </div>
      </router-link>

      <router-link to="/community" class="nav-card">
        <img src="../assets/社区缩略.png" alt="空军社区" class="nav-image">
        <div class="nav-content">
          <h3>空军社区</h3>
          <p>与其他钓鱼爱好者交流经验，分享战果</p>
        </div>
      </router-link>
    </div>

    <div class="features-section">
      <h2 class="section-title">为什么选择空军基地？</h2>
      <div class="features-container">
        <div class="feature-item">
          <div class="feature-icon">🎣</div>
          <h3>专业AI钓鱼指导</h3>
          <p>从新手到高手，我们提供全方位的钓鱼技巧和经验分享</p>
        </div>
        <div class="feature-item">
          <div class="feature-icon">🗺️</div>
          <h3>精准地图数据</h3>
          <p>覆盖全球的精准地图，实时更新地图实况信息</p>
        </div>
        <div class="feature-item">
          <div class="feature-icon">🐟</div>
          <h3>丰富鱼类知识</h3>
          <p>详尽的鱼类百科，了解各种鱼类的习性和钓法</p>
        </div>
        <div class="feature-item">
          <div class="feature-icon">👥</div>
          <h3>活跃社区交流</h3>
          <p>与万千钓鱼爱好者分享经验，交流心得</p>
        </div>
      </div>
    </div>

    <div class="stats-section">
      <div class="stats-container">
        <div class="stat-item">
          <div class="stat-number">精确地图</div>
          <div class="stat-label">切换自如</div>
        </div>
        <div class="stat-item">
          <div class="stat-number">100+</div>
          <div class="stat-label">鱼类信息</div>
        </div>
        <div class="stat-item">
          <div class="stat-number">n+</div>
          <div class="stat-label">活跃用户</div>
        </div>
        <div class="stat-item">
          <div class="stat-number">99%</div>
          <div class="stat-label">满意度</div>
        </div>
      </div>
    </div>

    <div class="popular-fish-section">
      <h2 class="section-title">热门鱼类推荐</h2>
      <div class="fish-cards">
        <div class="fish-card">
          <img src="../assets/鲫鱼.png" alt="鲫鱼" class="fish-image">
          <div class="fish-info">
            <h3>鲫鱼</h3>
            <p>最常见的淡水鱼之一，适应性强，分布广泛</p>
          </div>
        </div>
        <div class="fish-card">
          <img src="../assets/鲤鱼.png" alt="鲤鱼" class="fish-image">
          <div class="fish-info">
            <h3>鲤鱼</h3>
            <p>力量型鱼类，垂钓手感极佳，深受钓友喜爱</p>
          </div>
        </div>
        <div class="fish-card">
          <img src="../assets/草鱼.png" alt="草鱼" class="fish-image">
          <div class="fish-info">
            <h3>草鱼</h3>
            <p>草食性鱼类，体型较大，是理想的垂钓目标</p>
          </div>
        </div>
      </div>
    </div>

    <div class="testimonials-section">
      <h2 class="section-title">用户评价</h2>
      <div class="testimonials-container">
        <div class="testimonial-card">
          <div class="testimonial-content">
            "空军基地帮助我从钓鱼新手成长为高手，地图功能特别实用！"
          </div>
          <div class="testimonial-author">- 张先生，资深钓友</div>
        </div>
        <div class="testimonial-card">
          <div class="testimonial-content">
            "鱼类百科非常详细，让我了解了各种鱼类的习性和钓法，推荐！"
          </div>
          <div class="testimonial-author">- 李女士，钓鱼爱好者</div>
        </div>
        <div class="testimonial-card">
          <div class="testimonial-content">
            "社区氛围很好，可以和全国各地的钓友交流经验，收获满满。"
          </div>
          <div class="testimonial-author">- 王师傅，退休钓鱼人</div>
        </div>
      </div>
    </div>

    <div class="cta-section">
      <h2>{{ isLoggedIn ? '欢迎回到空军基地' : '立即加入空军基地' }}</h2>
      <p>{{ isLoggedIn ? '查看您的个人信息和活动记录' : '开启您的专业钓鱼之旅' }}</p>
      <button class="cta-button" :disabled="isLoading" @click="handleRegisterClick">
        <span v-if="!isLoading">{{ buttonText }}</span>
        <span v-else class="loading-spinner">↻</span>
      </button>
    </div>

    <div class="quote-section">
    <p class="fishing-quote">
      "钓鱼是一项修身养性的活动，让我们在宁静中感受自然的魅力，下一竿就是巨物！"
      <span class="quote-attribution">------专业空军大师---->赵涛</span>
    </p>
  </div>
  </div>
</template>


<script setup>
import { ref, computed } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const isLoading = ref(false)

// 检查用户登录状态
const isLoggedIn = computed(() => {
  const token = localStorage.getItem('token')
  return token && token.trim() !== ''
})

// 动态按钮文本
const buttonText = computed(() => {
  return isLoggedIn.value ? '进入个人中心' : '免费注册'
})

const handleRegisterClick = () => {
  if (isLoading.value) return
  
  if (isLoggedIn.value) {
    // 已登录用户直接跳转到个人中心
    router.push('/user-center')
    return
  }
  
  isLoading.value = true
  
  // 等待1秒后跳转到注册页面
  setTimeout(() => {
    isLoading.value = false
    router.push('/register')
  }, 1000)
}
</script>

<style scoped>
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.welcome-section {
  padding: 10px;
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border-radius: 10px;
  margin-bottom: 40px;
  background-image: url('../assets/main_25aw_pc.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.welcome-title {
  font-size: 42px;
  font-weight: bold;
  color: #0015ff;
}

.navigation-grid {
  display: flex;
  gap: 30px;
  margin-bottom: 60px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.nav-card {
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
  flex: 1 0 calc(25% - 30px);
  min-width: 250px;
}

.nav-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.nav-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.nav-content {
  padding: 20px;
}

.nav-content h3 {
  font-size: 22px;
  color: #0d47a1;
  margin-bottom: 10px;
}

.nav-content p {
  color: #555;
  font-size: 16px;
  line-height: 1.5;
}

.section-title {
  text-align: center;
  font-size: 32px;
  color: #0d47a1;
  margin-bottom: 40px;
  position: relative;
}

.section-title::after {
  content: "";
  display: block;
  width: 80px;
  height: 4px;
  background: #42a5f5;
  margin: 10px auto;
  border-radius: 2px;
}

.features-section {
  margin-bottom: 60px;
}

.features-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 30px;
}

.feature-item {
  text-align: center;
  padding: 30px 20px;
  border-radius: 10px;
  background: #f5f9ff;
  transition: all 0.3s ease;
}

.feature-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.feature-icon {
  font-size: 48px;
  margin-bottom: 20px;
}

.feature-item h3 {
  font-size: 22px;
  color: #0d47a1;
  margin-bottom: 15px;
}

.feature-item p {
  color: #555;
  font-size: 16px;
  line-height: 1.5;
}

.stats-section {
  background: linear-gradient(135deg, #42a5f5 0%, #1e88e5 100%);
  border-radius: 10px;
  padding: 40px 20px;
  margin-bottom: 60px;
}

.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 30px;
  text-align: center;
}

.stat-item {
  color: white;
}

.stat-number {
  font-size: 48px;
  font-weight: bold;
  margin-bottom: 10px;
}

.stat-label {
  font-size: 20px;
}

.popular-fish-section {
  margin-bottom: 60px;
}

.fish-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
}

.fish-card {
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.fish-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.fish-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.fish-info {
  padding: 20px;
}

.fish-info h3 {
  font-size: 22px;
  color: #0d47a1;
  margin-bottom: 10px;
}

.fish-info p {
  color: #555;
  font-size: 16px;
  line-height: 1.5;
}

.testimonials-section {
  margin-bottom: 60px;
}

.testimonials-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
}

.testimonial-card {
  background: #f5f9ff;
  border-radius: 10px;
  padding: 30px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.testimonial-content {
  font-size: 18px;
  color: #333;
  font-style: italic;
  margin-bottom: 20px;
  line-height: 1.6;
}

.testimonial-author {
  text-align: right;
  font-weight: bold;
  color: #0d47a1;
}

.cta-section {
  text-align: center;
  background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
  border-radius: 10px;
  padding: 60px 20px;
  margin-bottom: 60px;
  color: white;
}

.cta-section h2 {
  font-size: 36px;
  margin-bottom: 20px;
}

.cta-section p {
  font-size: 20px;
  margin-bottom: 30px;
}

.cta-button {
  background: white;
  color: #43a047;
  border: none;
  padding: 15px 40px;
  font-size: 20px;
  font-weight: bold;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.cta-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.quote-section {
  text-align: center;
  padding: 60px 20px;
  background: linear-gradient(135deg, #f1f8e9 0%, #dcedc8 100%);
  border-radius: 10px;
  margin-bottom: 40px;
}

.fishing-quote {
  font-size: 24px;
  font-style: italic;
  color: #33691e;
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.6;
  position: relative;
}
.quote-attribution {
  display: block;
  text-align: right;
  margin-top: 20px;
  font-size: 18px;
  color: #558b2f;
  font-style: normal;
}
.loading-spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
</style>